[IA64] sparse-merge: check SPARSEDIR for modifications
authorawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Sun, 21 May 2006 13:24:51 +0000 (07:24 -0600)
committerawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Sun, 21 May 2006 13:24:51 +0000 (07:24 -0600)
Check SPARSEDIR for modifications before allowing the merge.
This removes the need for the FIXME.  Additionally clean up
empty diffs at the end of the run.

Signed-off-by: Aron Griffis <aron@hp.com>
xen/arch/ia64/tools/sparse-merge

index dbca0c99beb790e7480f8155336509538bb09ec6..66433187c4f15dba3bd5b7ede7773f44eb6b83c6 100755 (executable)
 : ${ARCH:=ia64}
 
 SPARSEDIR=linux-2.6-xen-sparse
+WD=$PWD
 
 if [ ! -d $SPARSEDIR ]; then
        echo "Can't find $SPARSEDIR directory."
        exit
 fi
 
-WD=$PWD
-# We want the linux upsream tree to be at the OLDTAG to get the OLDTAG-Xen diff.
+# Check for modified files in the sparse tree before starting
+if hg st $SPARSEDIR | head | grep .; then
+    echo
+    echo "$SPARSEDIR contains modifications, please clean it up first"
+    exit
+fi
+
+# We want the linux upstream tree to be at the OLDTAG to get the OLDTAG-Xen diff.
 # Save current revision to restore when done
-cd $LINUXPATH
+cd $LINUXPATH || exit 1
 OLDCSET=$(hg parents | awk '/^changeset:/{print($2)}' | cut -f 1 -d :)
 for t in $OLDTAG $NEWTAG; do
     if ! hg tags | cut -f1 -d' ' | grep -Fx $t; then
@@ -36,6 +43,7 @@ for t in $OLDTAG $NEWTAG; do
     fi
 done
 hg up -C $OLDTAG || exit 1
+
 cd $WD
 for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep "$ARCH"); do
        cd $WD
@@ -58,9 +66,6 @@ for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep "$ARCH"); do
        cd $DIRNAME
        XENDIR=$(pwd)
 
-       ### FIXME ###
-       hg revert $FILENAME
-
        ORIGPATH=$(echo $i | sed -e "s/^$SPARSEDIR/./")
        APATH=$(echo $i | sed -e "s/^$SPARSEDIR/a/")
        BPATH=$(echo $i | sed -e "s/^$SPARSEDIR/b/")
@@ -85,7 +90,7 @@ for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep "$ARCH"); do
                fi
                TONEWREJ=$(wc -l ${FILENAME}.rej | \
                           awk '{print($1)}')
-               hg revert $FILENAME
+               hg st $FILENAME | grep -q . && hg revert $FILENAME
                rm -f ${FILENAME}.rej ${FILENAME}.orig
                diff -uN $DIFFPATH $FILENAME | \
                    sed -e "s,^--- $DIFFPATH,--- $FILENAME," \
@@ -134,6 +139,6 @@ for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep "$ARCH"); do
                        echo "SUCCESS (Upstream applied)"
        fi
 done
+find $SPARSEDIR -name \*.diff -empty | xargs -r rm -f
 cd $LINUXPATH
 hg up -C $OLDCSET
-cd $WD